package 自定义异常;

import java.util.Scanner;

/*
* 测试类
* */
public class Demo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入分数");
        int score = sc.nextInt();
        Teacher t = new Teacher();
        try {
            t.checkScore(score);
        } catch (ScoreException e) {
            e.printStackTrace();
        }
    }
}
/*
* 自定义异常类
* */
class ScoreException extends Exception{
    public ScoreException() {
    }
    public ScoreException(String message){
        super(message);
    }
}
/*
* 老师类
* */
class Teacher{
    public void checkScore(int score) throws ScoreException{
        if(score<0||score>100){
            /*采用throw的方式进行异常处理*/
            throw new ScoreException("你给的分数有误，分数应该在0-100之间");
        }else {
            System.out.println("成绩正常");
        }
    }
}